package com.bdqn.web.converter;

import org.apache.log4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 使用@InitBinder注解
 */
public class BaseController {
    private Logger logger=Logger.getLogger(BaseController.class);
    @InitBinder
    public void initBinder(WebDataBinder dataBinder){
        logger.info("进入BaseController的initBinder");
        dataBinder.registerCustomEditor(Date.class,new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"),true));
    }
}
